import base64

# 普通Base64可能在URL中出问题
token = b"sensitive+data/with+special/chars"
standard_b64 = base64.b64encode(token).decode('utf-8')
print(f"标准Base64: {standard_b64}")  # 包含+和/
print(base64.b64decode(standard_b64))


# URL安全的Base64
urlsafe_b64 = base64.urlsafe_b64encode(token).decode('utf-8')
print(f"URL安全Base64: {urlsafe_b64}")  # +变成-，/变成_
print(base64.urlsafe_b64decode(urlsafe_b64))
